<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { Folder, User, Location, Collection, Tools, Monitor, Box } from '@element-plus/icons-vue'

const router = useRouter()
const activeMenu = ref('employees')

const handleMenuSelect = (key) => {
  switch (key) {
    case 'employees':
      router.push('/admin/employees')
      break
    case 'site':
      router.push('/admin/site')
      break
    case 'component':
      router.push('/admin/component')
      break
    case 'equipment':
      router.push('/admin/equipment')
      break
    case 'module':
      router.push('/admin/module')
      break
    case 'label':
      router.push('/admin/label')
      break
  }
}
</script>

<template>
  <div class="manager-container">
    <!-- 左侧菜单 -->
    <div class="sidebar">
      <el-menu
        :default-active="activeMenu"
        class="sidebar-menu"
        @select="handleMenuSelect"
      >
        <el-menu-item index="employees">
          <el-icon><User /></el-icon>
          <span>员工管理</span>
        </el-menu-item>
        <el-menu-item index="site">
          <el-icon><Location /></el-icon>
          <span>站点管理</span>
        </el-menu-item>
        <el-menu-item index="equipment">
          <el-icon><Monitor /></el-icon>
          <span>机器管理</span>
        </el-menu-item>
        <el-menu-item index="module">
          <el-icon><Box /></el-icon>
          <span>模块管理</span>
        </el-menu-item>
        <el-menu-item index="component">
          <el-icon><Tools /></el-icon>
          <span>部件管理</span>
        </el-menu-item>
        <el-menu-item index="label">
          <el-icon><Box /></el-icon>
          <span>标签管理</span>
        </el-menu-item>
      </el-menu>
    </div>

    <!-- 右侧内容区 -->
    <div class="content">
      <router-view></router-view>
    </div>
  </div>
</template>

<style scoped>
.manager-container {
  display: flex;
  height: calc(100vh - 60px); /* 减去顶部导航栏的高度 */
  background-color: #fff;
}

.sidebar {
  width: 200px;
  border-right: 1px solid #e6e6e6;
  background-color: #fff;
}

.sidebar-menu {
  border-right: none;
}

.content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background-color: #f5f7fa;
}

:deep(.el-menu-item) {
  display: flex;
  align-items: center;
  padding-left: 20px !important;
}

:deep(.el-menu-item .el-icon) {
  margin-right: 8px;
}
</style> 